<?php

namespace App\Http\Controllers\Api\V1\Login;

use App\Http\Controllers\ApiBaseController;
use App\Libs\Commons\MyMessage;
use App\Services\Garage\AccountService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class GarageController extends ApiBaseController
{
    /**
     * 登陆 根据手机号
     * openid
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Libs\Commons\MyException
     */
	public function index(Request $request)
	{

		$param = $request->all();
        $param = array(
            'mobile'=>'15045268117',
            'openid'=>'1243',
            'code'=>'1',
        );
		$validator = Validator::make($param, [
			'mobile' => 'required',
			'openid' => 'required'
		]);

		if ($validator->fails()) {
			return $this->fail(MyMessage::ERROR, $validator->errors()->first());
		}
		$result = AccountService::login($param);
		return $this->success($result);
	}
}
